﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COFE.IO;
using COFE.Core.Utils;

namespace COFE.Core.Filter
{
    /// <summary>
    /// IEntryFilter that match file name.
    /// </summary>
    public class FileEntryFilter : IEntryFilter
    {
        public FileEntryFilter(string filePattern = "*")
        {
            _filePattern = filePattern;
        }

        private string _filePattern;
        public string Pattern { get { return _filePattern; } }

        public bool Matches(IInternalFileSystemInfoExA entry)
        {
            if (entry is IFileInfo)                
                return StringUtils.MatchFileMask(entry.Name, _filePattern);
            return false;
        }

        public override string ToString()
        {
            return "file=" + _filePattern;
        }
    }
}
